package com.gs.synedocket;

import android.app.Application;
import android.content.Intent;
import android.text.TextUtils;

import androidx.multidex.MultiDex;

import com.gs.synedocket.activity.LoginActivity;
import com.gs.synedocket.db.sqlite.DBManager;
import com.gs.synedocket.util.AppUtil;
import com.gs.synedocket.util.CrashHandler;
import com.uuzuche.lib_zxing.activity.ZXingLibrary;

public class MyApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        String processName = AppUtil.getInstance().getProcessName();
        AppUtil.getInstance().initContext(getApplicationContext());
        if (!TextUtils.isEmpty(processName) && processName.equals(getPackageName())) {
            ZXingLibrary.initDisplayOpinion(this);
            MultiDex.install(this);
            DBManager.getInstance().init();
            // 捕获全局异常
            CrashHandler crashHandler = CrashHandler.getInstance();
            crashHandler.init();
        }
    }

    public static void startLogin() {
        Intent intent = new Intent(AppUtil.getInstance().getContext(), LoginActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
        AppUtil.getInstance().getContext().startActivity(intent);
    }
}
